package com.amado.course35Concurrent;

import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * HashMap 非线程安全,HashMap是支持null键和null值的，而HashTable在遇到null时，会抛出NullPointerException异常
 * HashTable 线程安全，锁全表
 * ConcurrentMap 线程安全，分区锁
 *   所有用到hashTable的场景都可以使用ConcurrentMap,那为什么还需要HashTable？
 * Created by Administrator on 2018/7/28.
 */
public class S04ConcurrentMapTest {
    public static void main(String[] args) {
    	Map<String,String> hashtable = new Hashtable<>();
    	//get方法添加synchronized实现线程安全
    	hashtable.get("0");
    	Map<String,String> concurrentHashMap = new ConcurrentHashMap<>();
    	concurrentHashMap.get("0");
    }
    
}
